﻿/*
*  ┏┓　　　┏┓
*┏┛┻━━━┛┻┓
*┃　　　　　　　┃ 　
*┃　　　━　　　┃
*┃　┳┛　┗┳　┃
*┃　　　　　　　┃
*┃　　　┻　　　┃
*┃　　　　　　　┃
*┗━┓　　　┏━┛
*　　┃　　　┃神兽保佑 ！
*　　┃　　　┃代码无BUG！
*　　┃　　　┗━━━┓
*　　┃　　　　　　　┣┓
*　　┃　　　　　　　┏┛
*　　┗┓┓┏━┳┓┏┛
*　　　┃┫┫　┃┫┫
*　　　┗┻┛　┗┻┛ 
*　　　
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using HZ.Supervise.Model.Enum;
using HZ.Supervise.Model;
using System.Data;
using HZ.Supervise.IBLL;

namespace HZ.Supervise.Web.Secondphase.NewReport
{
    public partial class SunMarkList : BasePage
    {
        HZ.Supervise.IBLL.IExecuteContext i = HZ.Supervise.BLLFactory.ExecuteContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlArea.InitAreaID = CurrentAccount.GetUser().Org.Area.AreaID;
                //BindData();
            }
        }

        private void BindData()
        {
            int t = 0; 
            DataTable dt = i.GetSunMark(str(), this.AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out t);
            AspNetPager1.RecordCount = t;
            this.gvw.DataSource = dt;
            this.gvw.DataBind();
        }
        private string str()
        {
            string where = "";
            if (!string.IsNullOrEmpty(txtHospitalName.Text.Trim()))
            {
                where += " and b.hospitalname like '%" + txtHospitalName.Text.Trim() + "%'";
            }
            if (!string.IsNullOrEmpty(ddlLevel.SelectedValue))
            {
                where += " and Levels2='" + ddlLevel.SelectedValue + "'";
            }
            if (!string.IsNullOrEmpty(txtyear.Text.Trim()))
            {
                where += " and SunYear like '%" + txtyear.Text.Trim() + "%'";
            }
            if (!string.IsNullOrEmpty(txtmonth.Text.Trim()))
            {
                where += " and SunMonth = '" + txtmonth.Text.Trim() + "'";
            }
            if (ddlArea.SelectedAreaID == "510000")
            {
                where += "and b.areaid like '51%'";
            }
            else
            {
                where += "and b.areaid like '" + ddlArea.SelectedAreaID + "%'";
            }
            if (ddlsort.SelectedValue == "1")
            {
                where += " order by SunYear,SunMonth,MonthScore ";
            }
            else
            {
                where += " order by SunYear,SunMonth,MonthScore desc ";
            }
            return where;
        }
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="sender">事件发送源</param>
        /// <param name="e">事件参数</param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
        }

        /// <summary>
        /// 翻页显示
        /// </summary>
        /// <param name="sender">事件发送源</param>
        /// <param name="e">事件参数</param>
        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            BindData();
        }

        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Export_Click(object sender, EventArgs e)
        {
            int t = 0; 
            DataTable dt = i.GetSunMark(str(), 1, 0, out t);
            if (dt.Rows.Count > 0)
            {
                ExportFile.Instance.ExportData(dt, gvw, this);
            }
            else
            {
                HZ.Web.WebUtil.Alert("没有需导出的数据", Page);
            }
        }


    }
}